package demo05;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author: WangPeng
 * @createTime: 2022/11/04 17:23
 * @description:
 * @version: v1.0
 */
public class Test01 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        Collections.addAll(list, "张无忌", "周芷若", "赵敏", "张强", "张三丰");
        //1.获取所有姓张。
        List<String> listZhang = new ArrayList<>();
        for (String s : list) {
            if (s.startsWith("张")){
                listZhang.add(s);
            }
        }
        System.out.println(listZhang);
        //2. 名字中含有三个的字
        List<String> listThree = new ArrayList<>();
        for (String s : listZhang) {
            if (s.length()==3){
                listThree.add(s);
            }
        }
        System.out.println(listThree);
        //3.打印
        for (String s : listThree) {
            System.out.println(s);
        }
    }
}
